/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.eclipse.persistence.annotations.CascadeOnDelete;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "PackageType")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PackageType.findAll", query = "SELECT p FROM PackageType p"),
    @NamedQuery(name = "PackageType.findByPackageTypeID", query = "SELECT p FROM PackageType p WHERE p.packageTypeID = :packageTypeID"),
    @NamedQuery(name = "PackageType.findByPackageTypeDesc", query = "SELECT p FROM PackageType p WHERE p.packageTypeDesc = :packageTypeDesc"),
    @NamedQuery(name = "PackageType.findByPackageTypeVol", query = "SELECT p FROM PackageType p WHERE p.packageTypeVol = :packageTypeVol")})
public class PackageType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "PackageTypeID")
    private Integer packageTypeID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "PackageTypeDesc")
    private String packageTypeDesc;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PackageTypeVol")
    private float packageTypeVol;
    @Basic(optional = false)
    @NotNull
    @Column(name = "PackageNumItems")
    private int numItems;
    @Basic(optional = false)
    @NotNull
    @Column(name = "servingVessel")
    private boolean servingVessel;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fGIPackageID")
    private Collection<FinishedGoodsInventory> finishedGoodsInventoryCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "kegPackageID")
    private Collection<ScanTblKeg> kegCollection;
    @OneToMany(mappedBy = "tPBPkgType")
    private Collection<TastePanelBeer> tastePanelBeerCollection;
    @OneToMany
    @JoinTable(
        name="JTPackageTypeToVCP",
        joinColumns={ @JoinColumn(name="PackageTypeID", referencedColumnName="PackageTypeID")},
        inverseJoinColumns={ @JoinColumn(name="VCPID", referencedColumnName="VCPID", unique=true)}
    )
    private List<VesselCleaningProcedure> vcpCollection;
    @OneToMany
    @JoinTable(
        name="JTPackageTypeToLabType",
        joinColumns={ @JoinColumn(name="PackageTypeID", referencedColumnName="PackageTypeID")},
        inverseJoinColumns={ @JoinColumn(name="labTypeID", referencedColumnName="labTypeID", unique=true)}
    )
    private List<LabType> labCollection;
    @OneToMany(cascade=CascadeType.ALL, orphanRemoval = true)
    @CascadeOnDelete
    @JoinTable(
        name="JTPackageTypeToInvUsage",
        joinColumns={ @JoinColumn(name="PackageTypeID", referencedColumnName="PackageTypeID")},
        inverseJoinColumns={ @JoinColumn(name="InvUsageID", referencedColumnName="InvUsageID", unique=true)}
    )
    private List<InventoryUsage> invUsageCollection;

    public PackageType() {
    }

    public PackageType(Integer packageTypeID) {
        this.packageTypeID = packageTypeID;
    }

    public PackageType(Integer packageTypeID, String packageTypeDesc, float packageTypeVol) {
        this.packageTypeID = packageTypeID;
        this.packageTypeDesc = packageTypeDesc;
        this.packageTypeVol = packageTypeVol;
    }

    public Integer getPackageTypeID() {
        return packageTypeID;
    }

    public void setPackageTypeID(Integer packageTypeID) {
        this.packageTypeID = packageTypeID;
    }

    public String getPackageTypeDesc() {
        return packageTypeDesc;
    }

    public void setPackageTypeDesc(String packageTypeDesc) {
        this.packageTypeDesc = packageTypeDesc;
    }

    public float getPackageTypeVol() {
        return packageTypeVol;
    }

    public void setPackageTypeVol(float packageTypeVol) {
        this.packageTypeVol = packageTypeVol;
    }

    public int getNumItems() {
        return numItems;
    }

    public void setNumItems(int numItems) {
        this.numItems = numItems;
    }

    public List<VesselCleaningProcedure> getVcpCollection() {
        return vcpCollection;
    }

    public void setVcpCollection(List<VesselCleaningProcedure> vcpCollection) {
        this.vcpCollection = vcpCollection;
    }

    public List<LabType> getLabCollection() {
        return labCollection;
    }

    public void setLabCollection(List<LabType> labCollection) {
        this.labCollection = labCollection;
    }

    public List<InventoryUsage> getInvUsageCollection() {
        return invUsageCollection;
    }

    public void setInvUsageCollection(List<InventoryUsage> invUsageCollection) {
        this.invUsageCollection = invUsageCollection;
    }

    public boolean isServingVessel() {
        return servingVessel;
    }

    public void setServingVessel(boolean servingVessel) {
        this.servingVessel = servingVessel;
    }

    @XmlTransient
    public Collection<FinishedGoodsInventory> getFinishedGoodsInventoryCollection() {
        return finishedGoodsInventoryCollection;
    }

    public void setFinishedGoodsInventoryCollection(Collection<FinishedGoodsInventory> finishedGoodsInventoryCollection) {
        this.finishedGoodsInventoryCollection = finishedGoodsInventoryCollection;
    }

    @XmlTransient
    public Collection<ScanTblKeg> getKegCollection() {
        return kegCollection;
    }

    public void setKegCollection(Collection<ScanTblKeg> kegCollection) {
        this.kegCollection = kegCollection;
    }

    @XmlTransient
    public Collection<TastePanelBeer> getTastePanelBeerCollection() {
        return tastePanelBeerCollection;
    }

    public void setTastePanelBeerCollection(Collection<TastePanelBeer> tastePanelBeerCollection) {
        this.tastePanelBeerCollection = tastePanelBeerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (packageTypeID != null ? packageTypeID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PackageType)) {
            return false;
        }
        PackageType other = (PackageType) object;
        if ((this.packageTypeID == null && other.packageTypeID != null) || (this.packageTypeID != null && !this.packageTypeID.equals(other.packageTypeID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.PackageType[ packageTypeID=" + packageTypeID + " ]";
    }
    
}
